<template>
  <div>
    <div>
      <el-breadcrumb separator-class="el-icon-arrow-right" style="margin: 20px">
        <el-breadcrumb-item :to="{ path: '/' }">员工页</el-breadcrumb-item>
        <el-breadcrumb-item>活动管理</el-breadcrumb-item>
        <el-breadcrumb-item>活动列表</el-breadcrumb-item>
        <el-breadcrumb-item>活动详情</el-breadcrumb-item>
      </el-breadcrumb>
      <hr />
    </div>

    <el-page-header @back="goBack" content="修改信息"></el-page-header>

    <div>
      <el-form
        :rules="rules"
        :model="form"
        ref="form"
        class="demo-ruleForm"
        label-width="107px"
        style="margin-top: 20px"
      >
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" style="width: 90px"></el-input>
        </el-form-item>

        <el-form-item label="年龄" prop="age">
          <el-input
            type="age"
            v-model.number="form.age"
            autocomplete="off"
            style="width: 90px"
          ></el-input>
        </el-form-item>

        <el-form-item label="性别" prop="gender">
          <el-radio-group v-model="form.gender">
            <el-radio label="男"></el-radio>
            <el-radio label="女"></el-radio>
          </el-radio-group>
        </el-form-item>

        <el-form-item prop="ID_number" label="身份证号码">
          <el-input
            v-model.number="form.ID_number"
            style="width: 300px"
          ></el-input>
        </el-form-item>

        <el-form-item prop="phone" label="手机号">
          <el-input v-model.number="form.phone" style="width: 300px"></el-input>
        </el-form-item>

        <el-form-item prop="position" label="职位">
          <el-select v-model="form.region" placeholder="请选择职位">
            <el-option label="清洁工" value="qingjiegong"></el-option>
            <el-option label="经理" value="jingli"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item prop="address" label="请选择地址">
          <el-select v-model="form.address" placeholder="请选地址">
            <el-option label="上海市" value="shanghai"></el-option>
            <el-option label="北京市" value="beijing"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="出生日期" required>
          <el-col :span="11">
            <el-date-picker
              prop="birth"
              type="date"
              placeholder="选择日期"
              v-model="form.birth"
              style="width: 100%"
            ></el-date-picker>
          </el-col>
        </el-form-item>

        <el-form-item label="入职日期" required>
          <el-col :span="11">
            <el-date-picker
              prop="hiredate"
              type="date"
              placeholder="选择日期"
              v-model="form.hiredate1"
              style="width: 100%"
            ></el-date-picker>
          </el-col>
        </el-form-item>

        <el-form-item label="离职日期" required>
          <el-col :span="11">
            <el-date-picker
              prop="resignation_time"
              type="date"
              placeholder="选择日期"
              v-model="form.hiredate2"
              style="width: 100%"
            ></el-date-picker>
          </el-col>
        </el-form-item>

        <el-form-item prop="emergency_contact" label="紧急联系方式">
          <el-input
            v-model.number="form.emergency_contact"
            style="width: 300px"
          ></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="onSubmit('form')">确认</el-button>
          <el-button @click="resetForm('form')">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        name: "",
        age: "",
        address: "",
        hiredate1: "",
        hiredate2: "",
        birth: "",
        delivery: false,
        type: [],
        gender: "",
        desc: "",
        ID_number: "",
        phone: "",
        position: "",
        emergency_contact: "",
        hiredate:'',
        resignation_time:'',
      },
      rules: {
        name: [
          { required: true, message: "姓名不能为空", trigger: "blur" },
          {
            min: 2,
            max: 30,
            message: "长度在 2 到 30 个字符",
            trigger: "blur",
          },
        ],
        age: [
          { required: true, message: "年龄不能为空" },
          { type: "number", message: "年龄必须为数字值" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        gender: [{ required: true, message: "请选择性别", trigger: "change" }],
        ID_number: [
          { required: true, message: "号码不能为空" },
          { type: "number", message: "号码必须为数字值" },
          { min: 3, max: 18, message: "长度在 3 到 18 个字符", trigger: "blur" },
        ],
        address: [
          { required: true, message: "请选择地址", trigger: "change" },
        ],
        position: [
          { required: true, message: "请选择职位", trigger: "change" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        phone: [
          { required: true, message: "号码不能为空" },
          { type: "number", message: "号码必须为数字值" },
          { min: 3, max: 11, message: "长度在 3 到 11 个字符", trigger: "blur" },
        ],
        birth: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
        hiredate: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
        resignation_time: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
        emergency_contact: [
          { required: true, message: "号码不能为空", trigger: "blur" },
          { type: "number", message: "号码必须为数字值", trigger: "blur" },
          { min: 3, max: 11, message: "长度在 3 到 11 个字符", trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    goBack() {
      this.$router.back();
    },
    onSubmit(form) {
      console.log(this.$refs)
      this.$refs[form].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },

    resetForm(form) {
      this.$refs[form].resetFields();
    },
  },
};
</script>

<style>
</style>